#include"Stack.h"
void StackInit(Stack* st)
{
	st->_stack = NULL;
	st->_capacity = 0;
	st->_top = 0;
}
void StackPush(Stack* st, StackDataType data)
{
	assert(st);
	if (st->_capacity == st->_top)
	{
		int newCapacity = st->_capacity == 0 ? 4 : 2 * st->_capacity;
		st->_stack = (StackDataType*)realloc(st->_stack, newCapacity * sizeof(StackDataType));
		st->_capacity = newCapacity;
	}
	st->_stack[st->_top] = data;
	st->_top++;
}
void StackPop(Stack* st)
{
	assert(st);
	assert(st->_top);
	st->_top--;
}
StackDataType StcakTop(Stack* st)
{
	assert(st);
	return st->_stack[st->_top-1];
}
int StackSize(Stack* st)
{
	assert(st);
	return st->_top;
}
int StackEmpty(Stack* st)
{
	assert(st);
	if (st->_top == 0)
	{
		return 1;
	}
	else
	{
		return 0;
	}
}
void StackDestory(Stack* st)
{
	assert(st);
	if (st->_stack != NULL)
	{
		free(st->_stack);
	}
	st->_capacity = st->_top = 0;

}